package com.zy.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.zy.mapper.LinkmanMapper;
import com.zy.pojo.Supper;
import com.zy.service.LinkmanService;
import com.zy.vo.Supper.PageSto;
import com.zy.vo.Supper.SupperVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

@Service("linkmanService")
public class LinkmanServiceImpl extends ServiceImpl<LinkmanMapper, Supper> implements LinkmanService {


    @Resource
    private LinkmanMapper linkmanMapper;
    @Override
    public PageSto getPage(Integer pageNo, Integer pageSize, SupperVo supperVo) {
        Page page = new Page();
        page.setSize(pageSize);
        page.setCurrent(pageNo);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like(!StringUtils.isEmpty(supperVo.getSupperName()),"supper_Name",supperVo.getSupperName())
                .like(!StringUtils.isEmpty(supperVo.getSupperUsername()),"supper_Username",supperVo.getSupperUsername());
        List<Supper> list = linkmanMapper.getLinkmanList(page,queryWrapper);
        System.out.println(page.getTotal()+"+++++++++++++++++++++++++");
        return new PageSto(list,page.getTotal());
    }

    @Override
    public void getlinkmanadd(Supper supper) {
        linkmanMapper.insert(supper);
    }

    @Override
    public void getlinkmandel(Integer id) {
        linkmanMapper.deleteById(id);

    }

    @Override
    public void getlinkmanupdate(Supper supper) {
        linkmanMapper.updateById(supper);
    }
}
